package com.epro.dx.task;

import android.content.Context;
import android.os.AsyncTask;
import com.weipu.common.facade.factory.ProviderFactory;

/**
 *
 * 异步任务：获取版本号
 *
 * @author Zenglw
 * @version [1.0, 2017-6-15]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 *
 */
public class GetVersionTask extends AsyncTask<Void,Void,String> {
    private final Context mContext;
    private OnGetNewVersionCompletedListener listener;

    public GetVersionTask(Context context, OnGetNewVersionCompletedListener listener){
        this.mContext = context;
        this.listener = listener;
    }

    @Override
    protected String doInBackground(Void... params) {
        String version = ProviderFactory.createUpdateService().getVersion(mContext);
        return version;
    }

    @Override
    protected void onPostExecute(String s) {
        if (listener != null) {
            listener.OnGetNewVersionCompleted(s);
        }

    }

    public interface OnGetNewVersionCompletedListener{
        void OnGetNewVersionCompleted(String newVersionCode);
    }
}
